import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 销售团队信息信息 */
export interface BizSalesTeam {
          teamId: number; // 小组ID
          teamName?: string; // 小组名称
          teamCode: string; // 小组编号
          managerId: number; // 小组经理ID，关联销售人员表的员工ID
          departmentId: number; // 所属部门ID，关联部门表
          teamGoal: number; // 小组销售目标金额
          currentQuarterTarget: number; // 本季度销售目标
          teamDescription: string; // 小组描述信息
          establishmentDate: string | Dayjs; // 小组成立日期
          status: number; // 小组状态：1-活跃，0-已解散
          region: string; // 负责销售区域
          productFocus: string; // 重点销售产品类别
  }

// 销售团队信息 API
export const BizSalesTeamApi = {
  // 查询销售团队信息分页
  getBizSalesTeamPage: async (params: any) => {
    return await request.get({ url: `/saleTeam/biz-sales-team/page`, params })
  },

  // 查询销售团队信息详情
  getBizSalesTeam: async (id: number) => {
    return await request.get({ url: `/saleTeam/biz-sales-team/get?id=` + id })
  },

  // 查询已经分组的用户
  getBizSalesTeamUser: async (id: number) => {
    return await request.get({ url: `/saleTeam/biz-sales-team/getBizSalesTeamUser?id=` + id })
  },

  // 新增销售团队信息
  createBizSalesTeam: async (data: BizSalesTeam) => {
    return await request.post({ url: `/saleTeam/biz-sales-team/create`, data })
  },

  // 修改销售团队信息
  updateBizSalesTeam: async (data: BizSalesTeam) => {
    return await request.put({ url: `/saleTeam/biz-sales-team/update`, data })
  },

  // 删除销售团队信息
  deleteBizSalesTeam: async (id: number) => {
    return await request.delete({ url: `/saleTeam/biz-sales-team/delete?id=` + id })
  },

  /** 批量删除销售团队信息 */
  deleteBizSalesTeamList: async (ids: number[]) => {
    return await request.delete({ url: `/saleTeam/biz-sales-team/delete-list?ids=${ids.join(',')}` })
  },

  // 导出销售团队信息 Excel
  exportBizSalesTeam: async (params) => {
    return await request.download({ url: `/saleTeam/biz-sales-team/export-excel`, params })
  },
}
